home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Scripting / Source / StevesRgExp.h < prev   
Encoding:
Text File  |  1995-09-09  |  2.1 KB  |  78 lines  |  [TEXT/MPCC]

  1. /*---------------------------------------------------------------
  2.     Copyright 1995, Steve Israelson
  3.     
  4.     I own this code.  You are free to use this code in any software
  5.     you want.  You may not sell this source code at all, you can 
  6.     sell your product though.  If you want to include this code
  7.     in any code collection (CD-Roms etc) this is OK as long as
  8.     I get a complimentary copy.
  9.             Steve.
  10.     
  11.     Regular expressions.
  12. ---------------------------------------------------------------*/
  13. #pragma once
  14.  
  15. #include    <LList.h>
  16.  
  17. class RegExp 
  18.     {
  19. public:
  20.     enum    {    
  21.             kReg_Once,                 // match only once
  22.             kReg_ZeroOrMore,         // match 0 or more times
  23.             kReg_OneOrMore            // match one or more times
  24.             };
  25.     RegExp            *next;            // the expression that follows this one
  26.     long            ID;                // an identifier for this expression
  27.     short            type;            // a type from the above enumeration
  28.     Boolean            parameter;        // do we need to return our match?
  29.     
  30.     static RegExp     *Parse(char *text, RegExp*, long exprID);
  31.                     RegExp(long newID);
  32.                     ~RegExp();
  33.  
  34.     Boolean            Match(char *text, short start, short *last, LList *paramList);
  35.     virtual Boolean    MatchOne(char *text, short start, short *end);
  36.     };
  37.  
  38. class RBeginLine : public RegExp 
  39.     {
  40. public:
  41.                     RBeginLine(char *text, long newID);
  42.     virtual Boolean    MatchOne(char *text, short start, short *end);
  43.     };
  44.  
  45. class REndLine : public RegExp 
  46.     {
  47. public:
  48.                     REndLine(char *text, long newID);
  49.     virtual Boolean    MatchOne(char *text, short start, short *end);
  50.     };
  51.  
  52. class RSetExpr : public RegExp 
  53.     {
  54. public:
  55.     char    charSet[256];    // ascii allows for only 256 chars, right?
  56.  
  57.                     RSetExpr(char *text, long newID);
  58.     virtual Boolean    MatchOne(char *text, short start, short *end);
  59.     };
  60.  
  61. class RAnyChar : public RegExp 
  62.     {
  63. public:
  64.                     RAnyChar(char *text, long newID);
  65.     virtual Boolean    MatchOne(char *text, short start, short *end);
  66.     };
  67.  
  68. class ROrExpr : public RegExp 
  69.     {
  70. public:
  71.                     ROrExpr(char *text, long newID);
  72.     virtual Boolean    MatchOne(char *text, short start, short *end);
  73.     };
  74.  
  75. class RLiteral : public RegExp 
  76.     {
  77. public:
  78.     char        buffer[256];        // literals